package logic

import (
	"context"
	"shop-cart/api/internal/utils"
	"shop-cart/taobaorpc/taobaorpc"

	"shop-cart/api/internal/svc"
	"shop-cart/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CarListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCarListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CarListLogic {
	return &CarListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CarListLogic) CarList(req *types.CarListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.TaoBaoRpc.CarList(l.ctx, &taobaorpc.CarListRequest{
		UserId: req.UserId,
	})
	if err != nil {
		return utils.ReturnResponse(err.Error(), 0, nil)
	}
	return utils.ReturnResponse("购物车列表展示成功", 200, list)
}
